<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          :disabled="optType === 'view'||purchaseCode!=1"
          @click="handleAdd"
          v-hasPermi="['purchase:detail:add']"
        >新增</el-button>
        <ItemSelect ref="itemSelect" @onSelected="onItemSelected" > </ItemSelect>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single || optType === 'view'||purchaseCode!=1"
          @click="handleUpdate"
          v-hasPermi="['purchase:detail:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple || optType === 'view'||purchaseCode!=1"
          @click="handleDelete"
          v-hasPermi="['purchase:detail:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['purchase:detail:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="detailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="产品编码" align="center" prop="itemCode">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleView(scope.row)" v-hasPermi="['purchase:order:query']">{{ scope.row.itemCode }}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="产品名称" align="center" prop="itemName" />
      <el-table-column label="单位" align="center" prop="unitOfMeasure" />
      <el-table-column label="物料图片" align="center" prop="itemImgUrl" width="80">
        <template slot-scope="scope">
          <image-preview v-if="scope.row.itemImgUrl" :src="scope.row.itemImgUrl" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="采购总数" align="center" prop="quantity" width="100">
        <template slot-scope="scope">
          <el-input-number :disabled="optType === 'view' || purchaseCode!=1"
            v-model="scope.row.quantity"
            :min="1"
            :controls="true"
            :precision="0"
            size="mini"
            @change="(value) => handleQuantityChange(value, scope.row)"
          />
        </template>
      </el-table-column>
      <el-table-column label="已收数量" align="center" prop="receivedQuantity" width="100">
        <template slot-scope="scope">
          <el-input-number :disabled="optType === 'view'"
            v-model="scope.row.receivedQuantity"
            :min="0"
            :controls="true"
            :precision="0"
            size="mini"
            @change="(value) => handleReceivedQuantity(value, scope.row)"
          />
        </template>
      </el-table-column>
      <el-table-column label="待收数量" align="center" prop="waitedQuantity" width="100" />
      <el-table-column label="单价(元)" align="center" prop="unitPrice" width="100">
        <template slot-scope="scope">
          <el-input :disabled="optType === 'view'||purchaseCode!=1"
            v-model.number="scope.row.unitPrice"
            @change="(value) => handleUnitPriceChange(value, scope.row)"
            size="mini"
            style="width:80px;"
          />
        </template>
      </el-table-column>
      <el-table-column label="总金额(元)" align="center" prop="totalWithTax" width="100" />
      <el-table-column label="已付款(元)" align="center" prop="paidAmount" width="100">
        <template slot-scope="scope">
          <el-input :disabled="optType === 'view'"
            v-model.number="scope.row.paidAmount"
            size="mini"
            style="width:80px;"
            @change="(value) => handlePaidAmountChange(value, scope.row)"
          />
        </template>
      </el-table-column>
      <el-table-column label="应付款(元)" align="center" prop="payableAmount" width="100" />
      <el-table-column label="票据状态" align="center" prop="billCode" width="100">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.billCode">有</el-tag>
          <el-tag v-else type="info">无</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['purchase:detail:edit']" :disabled="optType === 'view'">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['purchase:detail:remove']" :disabled="optType === 'view'">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改采购单子项对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
              <el-form-item label="采购单ID" prop="purchaseId">
                <el-input v-model="form.purchaseId" placeholder="请输入采购申ID" disabled/>
              </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产品名称" prop="itemName">
              <el-input v-model="form.itemName" placeholder="请输入产品名称" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="产品编码" prop="itemCode">
              <el-input v-model="form.itemCode" placeholder="请输入产品编码" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="item主键" prop="itemId">
              <el-input v-model="form.itemId" placeholder="请输入item主键" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="specification">
              <el-input v-model="form.specification" type="textarea" placeholder="请输入规格型号" maxlength="100" disabled show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供应商" prop="vendorName">
              <el-input v-model="form.vendorName" readonly="readonly" placeholder="请选择供应商" :disabled="!isEdit">
                <el-button slot="append" @click="handleSelectVendor" icon="el-icon-search" :disabled="!isEdit"></el-button>
              </el-input>
              <VendorSelect ref="vendorSelect"
                            :itemId="form.itemId"
                            @onSelected="onVendorSelected" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商编码" prop="vendorCode" label-width="100">
              <el-input v-model="form.vendorCode" placeholder="供应商编码" style="width: 250px" :disabled="!isEdit"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="票据状态" prop="billCode">
              <el-select v-model="form.billCode"
                         placeholder="票据状态"  :disabled="optType == 'view'">
                <el-option
                    v-for="dict in dict.type.bill_code"
                    :key="dict.value"
                    :label="dict.label"
                    :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">

            <el-form-item label="单位" prop="unitOfMeasure">
              <el-input v-model="form.unitOfMeasure" placeholder="单位" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="物料图片" prop="itemImgUrl" label-width="110px">
              <image-preview   :src="form.itemImgUrl" :width="200" :height="200"  v-if="form.itemImgUrl"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="附件" prop="attachmentUrl" label-width="110px">
              <template v-if="isEdit">
                <file-upload v-model="form.attachmentUrl" :limit="1" placeholder="附件" />
              </template>
              <template v-else>
                <el-link type="primary" href="form.attachmentUrl">{{form.attachmentUrl}}</el-link>
              </template>
            </el-form-item>
          </el-col>

        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="预购数量" prop="quantity">
              <el-input v-model="form.quantity" placeholder="请输入数量" @change="handlePaidAmountChangeForm" :disabled="!isEdit||purchaseCode!=1"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="已购数量" prop="receivedQuantity">
              <el-input v-model="form.receivedQuantity" placeholder="请输入已购数量" :disabled="!isEdit"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="单价(元)" prop="unitPrice">
              <el-input v-model="form.unitPrice"   placeholder="请输入内容" @change="handlePaidAmountChangeForm" :disabled="!isEdit||purchaseCode!=1"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总额(元)" prop="totalWithTax">
              <el-input v-model="form.totalWithTax"   placeholder="请输入内容" disabled />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="已付金额(元)" prop="paidAmount" label-width="80">
              <el-input v-model="form.paidAmount"   placeholder="请输入内容" style="width: 250px;"   @change="handlePaidAmountChangeForm" :disabled="!isEdit"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="应付金额(元)" prop="payableAmount" label-width="80">
              <el-input v-model="form.payableAmount"   placeholder="请输入内容" style="width: 250px;" disabled/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="采购物品截图" prop="screenShotUrl" label-width="110px">
              <template v-if="isEdit">
                <image-upload v-model="form.screenShotUrl" :limit="1"  />
              </template>
              <template v-else>
                <img v-if="form.screenShotUrl" :src="form.screenShotUrl" id="screenShotUrl1" style="width:40% ;height: 40%;" @click="zoomImage('screenShotUrl1')"/>
              </template>
            </el-form-item>
          </el-col>


          <el-col :span="12">
            <el-form-item label="采购地址" prop="buyAddres">
              <el-input v-model="form.buyAddres" type="textarea"   placeholder="请输入采购地址" :disabled="!isEdit"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" :disabled="!isEdit"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


  </div>
</template>

<script>
import { listOrderDetail, getOrderDetail, delOrderDetail, addOrderDetail, updateOrderDetail } from "@/api/purchase/order/purchase-order-detail";
// import ItemSelect from "@/components/itemSelect/index.vue";


import ItemSelect from "@/components/itemSelect/item-purchase.vue"
import VendorSelect from "@/components/vendorSelect/single.vue";
import {Decimal} from "decimal.js"
export default {
  name: "Detail",
  components: { ItemSelect ,VendorSelect},
  dicts: ['bill_code'],
  props: {
    requestId: {
      type: [String, Number],
      required: true
    },
    purchaseCode:{
      type:[String,Number],
      required:true
    },
    optType: {
      type: String,
      required: true,
      default: 'add'
    }
  },
  computed: {
    isViewMode() {
      return this.optType === 'view';
    }
  },
  data() {
    return {
      isEdit:false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 采购申请单明细表格数据
      detailList: [],
      // 弹出层标题
      title: "",

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        purchaseId:null,
        orderBy: 'created_at',
        orderType: 'asc'
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        purchaseId: [
          { required: true, message: "采购申请单ID不能为空", trigger: "blur" }
        ],
        quantity: [
          { required: true, message: "订购数量不能为空", trigger: "blur" }
        ],
        unitPrice: [
          { required: true, message: "单价不能为空", trigger: "blur" }
        ],

      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleView(row){
      this.reset();
      this.isEdit=false;
      getOrderDetail(row.id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "采购申请单-子项信息";
      });
    },
    //供应商选择
    handleSelectVendor() {
      this.$refs.vendorSelect.showFlag = true;
    },
    //供应商选择弹出框
    onVendorSelected(obj) {
      if (obj != undefined && obj != null) {
        this.form.vendorId = obj.vendorId;
        this.form.vendorCode = obj.vendorCode;
        this.form.vendorName = obj.vendorName;
        this.form.vendorNick = obj.vendorNick;
      }
    },
    changeAndSave(handType) {
      console.log('changeAndSave--', this.form);
      if (!this.form.id) {
        console.log('新建');
        return false;
      }
    },
    handleBillCodeChange(value,row){
      const updateData = {
        id: row.id,
        purchaseId: this.requestId,
        billCode: value
      };
      updateOrderDetail(updateData).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.getList();
        // // 触发父组件的更新方法
        // console.log('--刷新父类', this.requestId);
        // this.$emit('data-changed', this.requestId);
        // console.log('调用完成');
      }).catch(() => {
        // // 如果保存失败，回滚数量
        // row.quantity = this.oldQuantity;
      });
    },
    // 物料选择弹出框
    onItemSelected(obj) {
      this.form.itemId = this.itemId;
      if (obj != undefined && obj != null) {
        obj.forEach(element => {
          // 检查是否已存在相同物料
          const existingItem = this.detailList.find(item => item.itemId === element.itemId);
          console.log('existingItem--', existingItem);
          if (existingItem) {
            this.$modal.msgError(`物料 ${element.itemName}(${element.itemCode}) 已存在，请勿重复添加`);
            return; // 跳过当前物料的添加
          }

          this.form.purchaseId = this.requestId;
          this.form.itemId = element.itemId;
          this.form.itemCode = element.itemCode;
          this.form.itemName = element.itemName;
          this.form.bomItemSpec = element.specification;
          this.form.unitOfMeasure = element.unitOfMeasure;
          this.form.itemOrProduct = element.itemOrProduct;
          this.form.itemImgUrl=element.imgUrl;
          this.form.quantity = 1;
          this.form.enableFlag = 'Y';
          this.form.tabName = this.tabName;
          addOrderDetail(this.form).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.getList();
          });
        });
      }
    },
    getList() {
      this.loading = true;
      if (this.requestId) { // 确保 requestId 存在
        this.queryParams.purchaseId = this.requestId;
        console.log('11---list==',this.queryParams);
        listOrderDetail(this.queryParams).then(response => {
          this.detailList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      } else {
        this.loading = false;
        console.warn('requestId is not set');
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        purchaseId: null,
        vendorId: null,
        vendorCode: null,
        vendorName: null,
        productCode: null,
        productName: null,
        quantity: null,
        receivedQuantity: null,
        unitPrice: null,
        totalWithoutTax: null,
        taxRate: null,
        totalWithTax: null,
        paidAmount: null,
        payableAmount: null,
        remarks: null,
        createdAt: null,
        updatedAt: null,
        createBy: null,
        updateBy: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    /*    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加采购申请单明细";
    },*/
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.isEdit=true;
      this.form.tabName = this.tabName; // 设置表单中的 tabName
      this.$refs.itemSelect.showFlag = true;
    },

    /** 提交按钮 */
    submitForm() {
      console.log('提交--######################',this.form);
      if(this.form.vendorCode==null){
        this.$modal.msgError("请选择供应商信息");
        return false;
      }
      this.$refs["form"].validate(valid => {
        if (valid) {
          console.log('提交--form',this.form);
          if (this.form.id != null) {
            updateOrderDetail(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
              this.$emit('data-changed', this.requestId);
            });
          } else {
            addOrderDetail(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
              this.$emit('data-changed', this.requestId);
            });
          }
        }else{
          return false;
        }
        // 触发父组件的更新方法
        this.$emit('data-changed', this.requestId);
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除采购明细编号为"' + ids + '"的数据项？').then(function () {
        return delOrderDetail(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
        this.$emit('data-changed', this.requestId);
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('purchase/detail/export', {
        ...this.queryParams
      }, `detail_${new Date().getTime()}.xlsx`)
    },
    /** 数量变化时的处理函数 */
    handleQuantityChange(value, row) {
      this.updateTotalWithTax(row);
      const updateData = {
        id: row.id,
        quantity: value,
        purchaseId: this.requestId,
        totalWithTax: row.totalWithTax
      };
      updateOrderDetail(updateData).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.getList();
        // 触发父组件的更新方法
        console.log('--刷新父类', this.requestId);
        this.$emit('data-changed', this.requestId);
        console.log('调用完成');
      }).catch(() => {
        // 如果保存失败，回滚数量
        row.quantity = this.oldQuantity;
      });
    },
    //已接收
    handleReceivedQuantity(value, row) {
      const updateData = {
        id: row.id,
        receivedQuantity: value,
        purchaseId: this.requestId,
      };
      updateOrderDetail(updateData).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.getList();
        // 触发父组件的更新方法
        console.log('--刷新父类', this.requestId);
        this.$emit('data-changed', this.requestId);
        console.log('调用完成');
      }).catch(() => {
        // 如果保存失败，回滚数量
        row.quantity = this.oldQuantity;
      });
    },

    handleUnitPriceChange(value, row) {
      console.log('---handleUnitPriceChange ---value-',value);
      this.updateTotalWithTax(row);
      const updateData = {
        id: row.id,
        unitPrice: value,
        purchaseId: this.requestId,
        totalWithTax: row.totalWithTax,
        paidAmount: row.paidAmount,
        payableAmount: row.payableAmount
      };
      updateOrderDetail(updateData).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.getList();
        // 触发父组件的更新方法
        console.log('--刷新父类', this.requestId);
        this.$emit('data-changed', this.requestId);
        console.log('调用完成');
      }).catch(() => {
        // 如果保存失败，回滚数量
        row.quantity = this.oldQuantity;
      });
    },
    handlePaidAmountChange(value, row) {
      console.log('----handlePaidAmountChange-----',row);
      console.log('----handlePaidAmountChange value-----',value);
      this.updateTotalWithTax(row);
      const updateData = {
        id: row.id,
        unitPrice: row.unitPrice,
        purchaseId: this.requestId,
        totalWithTax: row.totalWithTax,
        paidAmount: value,
        payableAmount: row.payableAmount
      };
      updateOrderDetail(updateData).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.getList();
        // 触发父组件的更新方法
        console.log('--刷新父类', this.requestId);
        this.$emit('data-changed', this.requestId);
        console.log('调用完成');
      }).catch(() => {
        // 如果保存失败，回滚数量
        row.quantity = this.oldQuantity;
      });
    },
    handlePaidAmountChangeForm() {
      console.log('----handlePaidAmountChangeForm-----',this.form);
      this.updateTotalWithTax(this.form);
    },
    // updateTotalWithTax(row) {
    //   console.log('---updateTotalWithTax----',row);
    //   // 计算总金额（总金额 = 单价 * 购买数量）
    //   // 使用 Decimal 进行精确计算
    //   const quantity = new Decimal(row.quantity || 0);
    //   const unitPrice = new Decimal(row.unitPrice || 0);
    //   const paidAmount = new Decimal(row.paidAmount || 0);
    //   // 计算总金额（总金额 = 单价 * 购买数量）
    //   let totalWithTax = quantity.mul(unitPrice);
    //
    //   // 更新 row 中的总金额属性，保留两位小数
    //   row.totalWithTax = totalWithTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toString();
    //   console.log('row--',row);
    //   //已付金额
    //   // const paidAmount=new Decimal(row.paidAmount || 0);
    //
    //   // 计算应付款（应付款 = 总金额 - 已付款）
    //   const payableAmount=  totalWithTax.minus(paidAmount)
    //       .toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toString();
    //   row.payableAmount=payableAmount;
    //   console.log('应付款',payableAmount);
    //   // 如果你需要将总金额显示为字符串格式，可以这样设置;
    //   // row.totalWithoutTax = totalWithTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toString();
    // },

     updateTotalWithTax(row) {
        console.log('---updateTotalWithTax----', row);

        // 使用 Decimal 进行精确计算
        const quantity = new Decimal(row.quantity || 0);
        const unitPrice = new Decimal(row.unitPrice || 0);
        const paidAmount = new Decimal(row.paidAmount || 0); // 确保已付金额也被转换为 Decimal

        // 计算总金额（总金额 = 单价 * 购买数量）
        let totalWithTax = quantity.mul(unitPrice);

        // 更新 row 中的总金额属性，保留两位小数
        row.totalWithTax = totalWithTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toString();
        console.log('row--', row);
        // 计算应付款（应付款 = 总金额 - 已付款）
        const payableAmount = totalWithTax.minus(paidAmount)
            .toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toString();
        // 如果应付款小于等于0，则设置为0，避免出现负值
        row.payableAmount = new Decimal(payableAmount).greaterThanOrEqualTo(0)
            ? payableAmount
            : '0.00';

        console.log('应付款', row.payableAmount);

        // 如果你需要将总金额显示为字符串格式，可以这样设置;
        // row.totalWithoutTax = totalWithTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toString();
    },
  }
};
</script>

<style scoped>
.el-input-number.el-input-number--mini {
  width: 130px;
}
.el-input-number .el-input__inner,
.el-input .el-input__inner {
  width: 180px !important; /* 使用 !important 强制覆盖 */
}
</style>
